<?php
namespace app\common\process;

use think\exception\ValidateException;

class Subsidiary extends Automatic {
    protected $pk = 'id';
    protected $ownerPk = 'oid';
    protected $row = 'row';
    protected $upk = 'id';
    protected $uid = 'uid';
    protected $field = [];
    protected $lookScene = 'look';
    protected $infoScene = 'info';
    protected $saveScene = 'save';
    protected $delScene = 'del';

    public function post($user) {
        $post = input('post.');
        $post[$this->uid] = $user[$this->upk];
        return $post;
    }

    protected function validate_info($ownerPk, $user) {
        $validate = $this->validate;
        $post[$this->ownerPk] = $ownerPk;
        $post[$this->uid] = $user[$this->upk];
        if (!$validate->scene($this->infoScene)->check($post)) {
            $this->error($validate->getError());
        }
    }

    protected function validate_look($ownerPk) {
        $validate = $this->validate;
        $post[$this->ownerPk] = $ownerPk;
        if (!$validate->scene($this->lookScene)->check($post)) {
            $this->error($validate->getError());
        }
    }
}